import bus from '@/bus'
let date = new Date()
let year = date.getFullYear()
let month = date.getMonth() + 1
if(month.toString().length == 1) {
  month = '0' + month
}
let currentYm = year + '-' + month
let data = {
  form: {
    date: `${currentYm}`,
    status: '',
    keyword: ''
  },
  options: {
    status: [{
      value: 10,
      label: '未到结算时间'
    }, {
      value: 11,
      label: '待结算'
    }, {
      value: 12,
      label: '已结算'
    }]
  },
  status: 'pass',
  totalItem: 1,
  pageSize: window.$pageSize,
  currentPage: 1,
  columns: [{
    title: '经销商',
    key: 'distributorName',
    align: 'left',
    minWidth: 200
  }, {
    title: '科室',
    key: 'departmentName',
    align: 'left',
    minWidth: 120
  }, {
    title: '时间',
    key: 'settleMonth',
    align: 'left',
    minWidth: 100
  }, {
    key: 'storeNum',
    align: 'right',
    minWidth: 120,
    renderHeader: (h) => {
      let oDiv = h('div', [
        h('span', '使用门店'),
        h('Icon', {
          props: {
            type: 'ios-help-circle'
          }
        })
      ])
      return h('Tooltip', {
        style: {
          cursor: 'pointer'
        },
        props: {
          transfer: true,
          placement: 'top',
          content: '该经销商下使用了优惠券的门店数量',
          maxWidth: '200'
        }
      }, [oDiv])
    }
  }, {
    key: 'couponAmount',
    align: 'right',
    minWidth: 150,
    renderHeader: (h) => {
      let oDiv = h('div', [
        h('span', '抵扣总额(元)'),
        h('Icon', {
          props: {
            type: 'ios-help-circle'
          }
        })
      ])
      return h('Tooltip', {
        style: {
          cursor: 'pointer'
        },
        props: {
          transfer: true,
          placement: 'top',
          content: '该经销商下优惠券抵扣的总金额(元)',
          maxWidth: '200'
        }
      }, [oDiv])
    }
  }, {
    key: 'ccsPlusCouponAmount',
    align: 'right',
    minWidth: 150,
    renderHeader: (h) => {
      let oDiv = h('div', [
        h('span', 'CCS+抵扣'),
        h('Icon', {
          props: {
            type: 'ios-help-circle'
          }
        })
      ])
      return h('Tooltip', {
        style: {
          cursor: 'pointer'
        },
        props: {
          transfer: true,
          placement: 'top',
          content: '该经销商下CCS+门店使用优惠券抵扣的总金额(元)',
          maxWidth: '200'
        }
      }, [oDiv])
    }
  }, {
    align: 'right',
    minWidth: 150,
    renderHeader: (h) => {
      let oDiv = h('div', [
        h('span', '非CCS+抵扣'),
        h('Icon', {
          props: {
            type: 'ios-help-circle'
          }
        })
      ])
      return h('Tooltip', {
        style: {
          cursor: 'pointer'
        },
        props: {
          transfer: true,
          placement: 'top',
          content: '该经销商下除了CCS+门店使用优惠券抵扣的总金额(元)',
          maxWidth: '200'
        }
      }, [oDiv])
    },
    render: (h, params) => {
      let row = params.row
      let t = row.couponAmount - row.ccsPlusCouponAmount
      return h('span', t)
    }
  }, {
    key: 'settlementAmount',
    align: 'right',
    minWidth: 150,
    renderHeader: (h) => {
      let oDiv = h('div', [
        h('span', '实际结算(元)'),
        h('Icon', {
          props: {
            type: 'ios-help-circle'
          }
        })
      ])
      return h('Tooltip', {
        style: {
          cursor: 'pointer'
        },
        props: {
          transfer: true,
          placement: 'top',
          content: '给该经销商下实际结算的金额(元)',
          maxWidth: '200'
        }
      }, [oDiv])
    }
  }, {
    title: '结算状态',
    key: 'settlementStatus',
    align: 'left',
    minWidth: 150,
    render: (h, params) => {
      let row = params.row
      let text = row.settlementStatus
      let x
      switch (text) {
        case 'NO_SETTLEMENT_TIME':
          x = '未到结算时间'
          break
        case 'PENDING_SETTLEMENT':
          x = '待结算'
          break
        case 'SETTLED':
          x = '已结算'
          break
      }
      return h('div', x)
    }
  }, {
    title: '操作',
    align: 'right',
    minWidth: 180,
    render: (h, params) => {
      let detail = h('Button', {
        props: {
          size: 'small',
          type: 'primary'
        },
        style: {
          marginRight: '5px'
        },
        on: {
          click: () => {
            bus.$emit('onDetail', { item: params.row })
          }
        }
      }, '查看')
      let balance = h('Button', {
        props: {
          size: 'small',
          type: 'primary',
          disabled: params.row.settlementStatus !== 'PENDING_SETTLEMENT'
        },
        on: {
          click: () => {
            bus.$emit('onBalance', { item: params.row })
          }
        }
      }, '确认结算')
      return h('div', [detail, balance])
    }
  }],
  data: []
}
export default data